// 获取歌曲播放链接

// const express = require('express');
// const app = express();
const crypto = require('crypto');
const Http = require('../util/request');

module.exports = (query, request) => {
    console.log(query.cookies)
    if(!('MUSIC_U' in query.cookies)) query.cookies._ntes_nuid = crypto.randomBytes(16).toString("hex");
    const data = {
        ids: '[' + query.query.id + ']',
        br: parseInt(query.query.br || 999000)
    };
    // console.log(query.cookies)
    Http(
        'POST', `https://interface3.music.163.com/eapi/song/enhance/player/url`, data,
        {crypto: 'weapi', cookie: query.cookies, proxy: query.proxy}
    ).then(res => {
        // request.append('Set-Cookie', res.cookie)
        request.json(res)
    }).catch( err => {
        request.json(err)
    })
};
